package heima.lm.oschina.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import butterknife.BindView;
import butterknife.ButterKnife;
import heima.lm.oschina.BaseApplication;
import heima.lm.oschina.R;
import heima.lm.oschina.adapter.EventItemVpAdapter;
import heima.lm.oschina.base.BaseActivity;

/**
 * Created by Administrator on 2017/4/6.
 */

public class ActivitiesActivity extends BaseActivity {

    @BindView(R.id.vp_activities)
    ViewPager mVpActivities;
    @BindView(R.id.tab_activities)
    TabLayout mTabActivities;
    @BindView(R.id.toolbar_aa)
    Toolbar mToolbar;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_activity);
        ButterKnife.bind(this);
        BaseApplication.mActivityList.add(this);
        initView();
        initData();
        initEvent();
    }

    //初始化数据
    private void initData() {
        //设置适配器设置viewpager
        mVpActivities.setAdapter(new EventItemVpAdapter(getSupportFragmentManager()));
        //TabLayout与Vipager相结合使用
        mTabActivities.setupWithViewPager(mVpActivities);
    }

    private void initView() {
        setSupportActionBar(mToolbar);
        mToolbar.setTitle("活动");
        mToolbar.setNavigationIcon(R.drawable.actionbar_back_icon_normal);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivitiesActivity.this.finish();
            }
        });
    }

    private void initEvent() {
        mToolbar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivitiesActivity.this.finish();
            }
        });
    }

}
